#include "BufferWriter.h"


using namespace OOPUtils;




OOPUtils::BufferWriter::BufferWriter (StreamWriter & writer,
		size_t bufferSize) : _refWriter (writer), _buffer (bufferSize),
		_bufferStartPos (0), _curPtrInBuffer (0)
{

}


BufferWriter::~BufferWriter ()
{

}

void OOPUtils::BufferWriter::resetPos ()
{
	_refWriter.resetPos ();
}

void OOPUtils::BufferWriter::write (OOPPtr< ByteArray > data)
{
	size_t writerPos = _refWriter.getPos ();
	if (writerPos < _bufferStartPos || writerPos >=
			_bufferStartPos + _buffer.size ()) {
		flush ();
	}
}

void OOPUtils::BufferWriter::skip (size_t count)
{
	_refWriter.skip (count);
}

void OOPUtils::BufferWriter::setPos (size_t pos)
{
	_refWriter.setPos (pos);
}

size_t OOPUtils::BufferWriter::getPos ()
{
	return _refWriter.getPos ();
}

void OOPUtils::BufferWriter::flush ()
{

}
